package frontend.parser.syntaxtree;

import frontend.lexer.TKType;
import frontend.parser.syntaxtree.symbol.NonTerminalSymbol;
import frontend.parser.syntaxtree.symbol.TerminalSymbol;

import java.util.function.Consumer;

/**
 * forStmt 循环
 *
 * @author 杨凯伟
 * @date 2024/10/14
 */
public class ForStmtNode extends SyntaxNode {
    public LValNode lVal;
    public ExpNode exp;

    @Override
    public void walk(Consumer<TerminalSymbol> terConsumer, Consumer<NonTerminalSymbol> nonTerConsumer) {
        lVal.walk(terConsumer, nonTerConsumer);

        terConsumer.accept(new TerminalSymbol(TKType.ASSIGN));

        exp.walk(terConsumer, nonTerConsumer);

        nonTerConsumer.accept(new NonTerminalSymbol(this));
    }

    @Override
    public String getType() {
        return "ForStmt";
    }
}
